//
//  SynchronousOperation.swift
//  ScaffoldKit
//
//  Created by SuXinDe on 2018/7/29.
//  Copyright © 2018年 su xinde. All rights reserved.
//

import Foundation

public class SynchronousOperation: ConcurrentOperation {

    private let semaphore = Semaphore()
    
    override public var isAsynchronous: Bool {
        return false
    }
    
    override public func finish() {
        semaphore.continue()
    }
    
    override public func cancel() {
        super.cancel()
        semaphore.continue()
    }
    
    override public func execute() {
        super.execute()   
        semaphore.wait()
    }
}
